<?php
$userInfo = new stdClass();
if((Session::instance()->get('userId','')!=''))
{
	$userInfo->username = Session::instance()->get('username');
	$userInfo->userId = Session::instance()->get('userId');
	$userInfo->email = Session::instance()->get('email');
}
$avatar = url::base().'media/img/default-avatar.jpg';
if(!empty($userInfo->email)){
$avatar = gravatar::get($userInfo->email,24);
}

//下拉列表
$lans = Kohana::config('language.lan');
$lans = array_combine($lans,$lans);//构造类似array('php'=>'php','ruby'=>'ruby')这样的数组
$lans[] = '所有语言';
$lans = array_reverse($lans);
$lans_selection = form::dropdown('lan',$lans,'standard');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

<!--[if lt IE 7]>
<?php
echo html::script(array('media/script/IE7'));
?>
<![endif]-->

<?php
if(Router::$method == 'detail')
{
	echo html::stylesheet(array('media/css/markitup.css','media/css/markitup.toolbar.css','media/css/syntax/shCore.css'));
}
?>

<link href="<?php echo url::site('minify') ?>?files=media/css/TextboxList.Autocomplete.css,media/css/syntax/shThemeDefault.css,media/css/base.css,media/css/main.css&type=css" type="text/css" rel="stylesheet" />

<script type="text/javascript" src="<?php echo url::site('minify') ?>?files=media/script/jquery-1.3.2.min.js,media/script/markitup.pack.js,media/script/markitup.set.js,media/script/syntax/shCore.js,media/script/main.js&type=javascript"></script>

<?php
if(Router::$method == 'setting')
{
	echo html::stylesheet(array('media/css/TextboxList.css'));
	echo html::script(array('media/script/GrowingInput.js','media/script/TextboxList.js','media/script/TextboxList.Autocomplete.js','media/script/TextboxList.Autocomplete.Binary.js'));
}
?>
<title>
<?php echo (!isset($title)?'首页':$title);?>
</title>
</head>

<body>
<div class="bdotted">
	<div id="head">
		<div class="fl pt5">
			<a href="<?php echo url::site(); ?>"><img src="<?php echo url::base().'media/' ?>img/logo.png" /></a>
			<?php if((Session::instance()->get('userId','')!='')){ ?>
			<div class="pt10">
				<a href="<?php echo url::site(); ?>" class="mr10">首页</a> 
				<a href="<?php echo url::site('user') ?>" class="mr10">我的页面</a>
				<a href="<?php echo url::site('user/pubcode'); ?>" class="fwb fcf60">发布代码</a>
			</div>
			<?php } ?>
		</div>
		<div class="fr pt5 clear fs12 fc666">
			<div class="clear">
				<div class="fr">
			<?php if(!empty($userInfo->userId)){ ?>
			<img class="pr5" width="24" height="24" src="<?php echo $avatar; ?>" />欢迎 <a href="<?php echo url::site('user/setting'); ?>" class="ml5"><?php echo $userInfo->username; ?></a> <a href="<?php echo url::site('user/logout'); ?>" class="ml5">退出</a>
			<?php }else{?>
			<a href="<?php echo url::site('user/login');?>">登录/注册</a>
			<?php } ?>
				</div>
			</div>
			<div class="search pt15 fr">
				<form action="<?php echo url::site('code/search'); ?>" method="GET">
				<input type="text" name="keyword" value="" class="w150" />
				<?php echo $lans_selection; ?>
				<input type="submit" value="搜 索" style=""/>
				</form>
			</div>
		</div>
	</div>
</div>
